package com.zz.cinema.domain;

import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

@Entity
@Table(name = "TS_ITEMON")
public class TS_ItemON {

	/**
	 * create sequence SEQ_TS_CUSTOMER 
	 * minvalue 60000000 
	 * maxvalue 69999999
	 * start with 60000000
	 * increment by 1
	 * cache 20;
	 */
	@Id
	@GeneratedValue(generator = "sequenceGenerator_TS_ITEMON", strategy = GenerationType.SEQUENCE)
	@SequenceGenerator(name = "sequenceGenerator_TS_ITEMON", sequenceName = "SEQ_TS_ITEMON", initialValue = 60000000, allocationSize = 1)
	private int itemONId;
	
	private Date onDate;
	
	private double ticketPrice;
	
	@ManyToOne(cascade = CascadeType.ALL, targetEntity = TS_Cinema.class, fetch = FetchType.LAZY)
	@JoinColumn(name = "cinemaId", referencedColumnName = "cinemaId")
	private TS_Cinema cinema;
	
	@ManyToOne(cascade = CascadeType.ALL, targetEntity = TS_Hall.class, fetch = FetchType.LAZY)
	@JoinColumn(name = "hallId", referencedColumnName = "hallId")
	private TS_Hall hall;
	
	@ManyToOne(cascade = CascadeType.ALL, targetEntity = TS_Movie.class, fetch = FetchType.LAZY)
	@JoinColumn(name = "movieId", referencedColumnName = "movieId")
	private TS_Movie movie;

	public TS_ItemON() {
		super();
	}

	public TS_ItemON(Date onDate, double ticketPrice, TS_Cinema cinema, TS_Hall hall, TS_Movie movie) {
		super();
		this.onDate = onDate;
		this.ticketPrice = ticketPrice;
		this.cinema = cinema;
		this.hall = hall;
		this.movie = movie;
	}

	public int getItemONId() {
		return itemONId;
	}

	public void setItemONId(int itemONId) {
		this.itemONId = itemONId;
	}

	public Date getOnDate() {
		return onDate;
	}

	public void setOnDate(Date onDate) {
		this.onDate = onDate;
	}

	public double getTicketPrice() {
		return ticketPrice;
	}

	public void setTicketPrice(double ticketPrice) {
		this.ticketPrice = ticketPrice;
	}

	public TS_Cinema getCinema() {
		return cinema;
	}

	public void setCinema(TS_Cinema cinema) {
		this.cinema = cinema;
	}

	public TS_Hall getHall() {
		return hall;
	}

	public void setHall(TS_Hall hall) {
		this.hall = hall;
	}

	public TS_Movie getMovie() {
		return movie;
	}

	public void setMovie(TS_Movie movie) {
		this.movie = movie;
	}

	@Override
	public String toString() {
		return "TS_ItemON [itemONId=" + itemONId + ", onDate=" + onDate + ", ticketPrice=" + ticketPrice + ", cinema="
				+ cinema + ", hall=" + hall + ", movie=" + movie + "]";
	}
	
}
